import { createSlice, PayloadAction } from "@reduxjs/toolkit";

const defaultITimerValue: Slice.IItemTaskTimerSlice = { date: new Date().getTime() };

const taskDateTimerSlice = createSlice({
  name: "taskDateTimer",
  initialState: defaultITimerValue,
  reducers: {
    set: (state, action: PayloadAction<Slice.IItemTaskTimerSlice>) => {
      state = action.payload;
      return state;
    },
    reset: state => {
      state.date = new Date().getTime();
      return state;
    },
  },
});

export { taskDateTimerSlice };
